package cn.xuchunh.campusbbs.ui.activities;

import android.support.v4.app.FragmentTransaction;
import android.view.View;

import cn.xuchunh.campusbbs.base.BaseActivity;
import cn.xuchunh.campusbbs.base.BaseFragment;

/**
 * Created by XuChunH on 2015/10/17.
 */
public abstract class FragmentContainerActivity<T extends BaseFragment> extends BaseActivity {

    private int containerId = -1;

    @Override
    protected void initView(View view) {
        containerId = containerId();
        if (containerId != -1 && getFrament() !=null) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(containerId, getFrament());
            ft.commit();
        }
    }

    protected abstract T getFrament();
    protected abstract int containerId();

    public void setContainerId(int containerId) {
        this.containerId = containerId;
    }
}
